<?php
include_once ("../Login/databaseconnection.php");
$q=$_GET["q"];
$cs=explode(",",$q);
$Anal_in=$cs[0];
$Anal_val=$cs[1];
$hint='';
$Schools='';
$resultsch = mysql_query("SELECT * FROM school WHERE ".$Anal_in."='".$Anal_val."'");
if($resultsch)
{
while($rowSch=mysql_fetch_array($resultsch))
{
if(empty($Schools))
{
$Schools='"'.$rowSch['School_Id'].'"';
}
else
{
$Schools=$Schools.',"'.$rowSch['School_Id'].'"';
}
}
}
$resulttable = mysql_query("SELECT DISTINCT(Exam_Name) FROM exam WHERE School_Id in(".$Schools.")");
if($resulttable)
{
$hint=$hint.'<table><tr><td></td><td>Exam name: </td><td><select name="Exam_Name" onChange="getExaSubject(this.value)"><option value="Select One">Select One</option>';
while($rowtable=mysql_fetch_array($resulttable))
{
$Exam_Name=$rowtable['Exam_Name'];
$hint=$hint.'<option value="'.$Exam_Name.'">'.$Exam_Name.'</option>';
}
$hint=$hint.'</select></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr></table>';
}
  if($hint=='')
{ 
 $response=$response.'<font color="red">Please type correct '.$Anal_in.'</font><table>';
 $exa=mysql_query("SELECT DISTINCT(Exam_Name) FROM exam");
	$hint=$hint.'<table><tr><td></td><td>Exam name: </td><td><select name="Exam_Name" onChange="getExaSubject(this.value)" disabled="disabled"><option value="Select One">Select One</option>';
while($row=mysql_fetch_array($exa))
{
$Exam_Name=$row['Exam_Name'];
 $response=$response.'<option value="'.$Exam_Name.'">'.$Exam_Name.'</option>';
}
 $response=$response.'</select></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr></table>';
}
else
{
$response=$hint;
}
echo $response;
 ?>